<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<title>商户登陆页面</title>
		<link rel="Shortcut Icon" href="bitbug_favicon.ico">
		<link rel="stylesheet" href="css/base.css" />
		<!-- Bootstrap Core CSS -->
		<link href="sbadmin/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
		<!-- MetisMenu CSS -->
		<link href="sbadmin/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
		<!-- Custom CSS -->
		<link href="sbadmin/dist/css/sb-admin-2.css" rel="stylesheet">
		<link rel="stylesheet" href="css/common.css" />
		<!-- Custom Fonts -->
		<link href="sbadmin/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
		<style>
			html,
			body {
				background: #363636;
			}
			
			.admin-login-bg {
				text-align: center;
				margin-top: 154px;
			}
			
			.admin-login-bg img {
				width: 695px;
				height: 128px;
			}
		</style>
	</head>

	<body>
		<div class="admin-login">
			<div class="admin-login-bg">
				<img src="img/login-logo.png">
			</div>
			<div class="login-tebox">
				<div class="login-input-div">
					<input type="text" class="login-input" id="accName" placeholder="请输入账号" />
				</div>
				<div class="login-input-div mt15">
					<input type="password" class="login-input" id="password" placeholder="请输入密码" />
				</div>
				<button class="login-btn">确认登录</button>
			</div>

		</div>
		<!-- jQuery -->
		<script src="sbadmin/bower_components/jquery/dist/jquery.min.js"></script>

		<!-- Bootstrap Core JavaScript -->
		<script src="sbadmin/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

		<!-- Metis Menu Plugin JavaScript -->
		<script src="sbadmin/bower_components/metisMenu/dist/metisMenu.min.js"></script>
		<!-- Custom Theme JavaScript -->
		<script src="sbadmin/dist/js/sb-admin-2.js"></script>
		<script type="text/javascript" src="js/layer/layer.js"></script>
		<script>
			$(".login-btn").click(function() {
				//setTimeout("window.location.href='index.html'", 1000)
				var accName = $("#accName").val();
				var password = $("#password").val();
				var post_data = {
					identifier: accName,
					credential: password
				};
				if(accName == "" || password == "") {
					layer.msg("用户名或帐号不能为空！", {
						offset: '20%'
					});
				} else {
					$.ajax({
						url: "https://order.wz1996.wang/wzbg/login/employee",
						type: 'post',
						contentType: 'application/json',
						data: JSON.stringify(post_data),
						success: function(data) {
							console.log(data);
							//登录状态
							if(data.code == "1") {
								layer.msg("登录成功！", {
									offset: '20%'
								});
								localStorage.setItem("token", data.data.login.token);
								localStorage.setItem("adminName", accName);
								localStorage.setItem("isType", data.data.user.type);
								setTimeout("window.location.href='index.html'", 1000)
							} else {
								layer.msg(data.msg, {
									offset: '20%'
								});
							}
						},
						error: function(e) {
							layer.msg("账号或密码不正确！", {
								offset: '20%'
							});
						}
					});

				}
			})
		</script>
	</body>

</html>